/* Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.activiti.engine.impl.persistence.entity;

import java.io.Serializable;

/**
 * 表 ACT_GE_BYTEARRAY 用于保存与流程引擎相关的资源，只要调用了 Activiti 存储服
 * 务的 API，涉及的资源均会被转换为 byte 数组保存到这个表中。在资源表中设计了一个 BYTES
 * 宇段，用来保存资源的内容，因此理论上其可以用于保存任何类型的资源（文件或者其他来源
 * 的输入流）。一般情况下， Activiti 使用这个表来保存字符串、流程文件的内容、流程图片内容。
 */
public class ResourceEntityImpl extends AbstractEntityNoRevision implements ResourceEntity, Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 资源名称
     */
    protected String name;
    /**
     * 资源内容，数据类型为 longblob，最大可存 4GB 数据 。
     */
    protected byte[] bytes;
    /**
     *  一次由曙可以添加多个资源，该字段与剖曙表 ACT 阻 DEPI.DYMENT的主键相关联
     */
    protected String deploymentId;
    /**
     * 是否由 Activiti 自动产生的资源， 0表示 false, 1为true。
     */
    protected boolean generated;

    public ResourceEntityImpl() {

    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public byte[] getBytes() {
        return bytes;
    }

    public void setBytes(byte[] bytes) {
        this.bytes = bytes;
    }

    public String getDeploymentId() {
        return deploymentId;
    }

    public void setDeploymentId(String deploymentId) {
        this.deploymentId = deploymentId;
    }

    public Object getPersistentState() {
        return ResourceEntityImpl.class;
    }

    public void setGenerated(boolean generated) {
        this.generated = generated;
    }

    /**
     * Indicated whether or not the resource has been generated while deploying rather than being actual part of the deployment.
     */
    public boolean isGenerated() {
        return generated;
    }

    // common methods //////////////////////////////////////////////////////////

    @Override
    public String toString() {
        return "ResourceEntity[id=" + id + ", name=" + name + "]";
    }
}
